package com.jzg.jcptadmin.adpter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.jzg.jcptadmin.R;
import com.jzg.jcptadmin.base.MBaseAdapter;
import com.jzg.jcptadmin.data.vo.CarTypeSelectModel;

import java.util.List;


public class CarDiffListAdapter extends MBaseAdapter {

    private LayoutInflater inflater;
    private List<CarTypeSelectModel.DataBean.ListBeanX.ListBean> list;

    public CarDiffListAdapter(Context context, List<CarTypeSelectModel.DataBean.ListBeanX.ListBean> list) {
        this.inflater = LayoutInflater.from(context);
        this.list = list;
    }


    @Override
    public int getCount() {
        return list == null ? 0 : list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.item_car_diff_list, null);
            holder = new ViewHolder();

            holder.tvCarName = (TextView) convertView.findViewById(R.id.tvCarName);

            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.tvCarName.setText(list.get(position).getName()+" "+list.get(position).getYear()+"款");
        return convertView;
    }

    private class ViewHolder {
        TextView tvCarName;
    }


}
